function mapChildren(children, func, context) {
    //TODO实现此mapChildren方法
    children = Array.isArray(children) ? children: [children]
    let newArr = [];
    let index = 0;
    function flatMap(kids, key){
        kids.forEach((kid, i) => {
            if (Array.isArray(kid)) {
                key += `${i}:`
                flatMap(kid, key);
            }else{
                const domkey = kid.key ? `$${kid.key}`: `${i}`;
                let res = func(kid, index);
                res = Array.isArray(res)? res: [res];
                res.forEach(child => {
                    child.key = `${key}${domkey}/.$${child.key? child.key: i}`;
                    newArr.push(child);
                });
                index++;
            }
        });
    }
    flatMap(children, '.');

    // children = children.flat(Infinity).map(func).flat();

    return newArr;
}

export {
    mapChildren as map,
};